package edu.bupt.changelog.demo.service;

import edu.bupt.changelog.demo.service.dto.AgentDO;
import edu.bupt.changelog.demo.service.dto.QueryAgentRequest;
import edu.bupt.changelog.demo.service.mapper.LogAgentService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class LogAgentServiceImpl implements LogAgentService {

    public static Map<Long,AgentDO> map = new HashMap<>();


    public AgentDO get(QueryAgentRequest request){
        return map.get(request.getAgentId());
    }


    public void insert(QueryAgentRequest agent){
        AgentDO agentDO = new AgentDO();
        agentDO.setAgentId(agent.getAgentId());
        agentDO.setAgentName(agent.getName());
        agentDO.setManager(agent.getManager());
        map.put(agentDO.getAgentId(),agentDO);
    }

    public void update(QueryAgentRequest req){
        AgentDO agentDO = map.get(req.getAgentId());
        agentDO.setAgentName(req.getName());
        agentDO.setManager(req.getManager());
    }


    public void update(AgentDO req){
        AgentDO agentDO = map.get(req.getAgentId());
        agentDO.setAgentName(req.getAgentName());
        agentDO.setManager(req.getManager());
    }




    public void delete(QueryAgentRequest req){
        map.remove(req.getAgentId());
    }


}
